package com.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;

@WebServlet("/addressServlet")
public class addressServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        String name = req.getParameter("name");
        String address = new String(req.getParameter("address").getBytes("ISO-8859-1"),"UTF-8");
        String cardcheck = req.getParameter("cardcheck");
        String cardnumber = req.getParameter("cardnumber");
        HttpSession session = req.getSession();
        session.setAttribute("name",name);
        session.setAttribute("address",address);
        session.setAttribute("cardcheck",cardcheck);
        session.setAttribute("cardnumber",cardnumber);
        resp.sendRedirect("/webWork/step3.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
